import en from '../i18n/lang/en'
import Vue from 'vue'
import Router from 'vue-router'
import CommerViews from '@/views/commerViews'
import Login from '@/views/login/index'
import Layout from '@/views/layout/layout'
import HomeMain from '@/views/index/mainIndex'
import UserDetail from '@/views/user/UserDetail'
import UserAdd from '@/views/user/UserAdd'
import UserList from '@/views/user/UserList'
import examSetting from '@/views/examSetting/ExamSetting'
// 不是必须加载的组件使用懒加载
const Exam = () => import('@/views/exam/index')
const NotFound = () => import('@/page404')
const AddArticle = () => import('@/views/article/addArticle')
const AddArticleEditor = () => import('@/views/article/addArticleEditor')
const addLesson = () => import('@/views/lesson/lessonEditor')
const lessonEditor = () => import('@/views/lesson/lesson1')
const ChangePass = ()=>import ('@/views/user/ChangePass')

Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  { path: '/',
    redirect: '/index',
    hidden: true,
    children: []
  },
  {
    path: '/login',
    component: Login,
    name: '',
    hidden: true,
    children: []
  },
  {
    path: '/index',
    iconCls: 'fa fa-dashboard', // 图标样式class
    name: routeName.home,
    component: Layout,
    alone: true,
    children: [
      {
        path: '/index',
        iconCls: 'fa fa-dashboard', // 图标样式class
        name: '主页',
        component: HomeMain,
        children: []
      }
    ]
  },
  {
    path: '/404',
    component: NotFound,
    name: '404',
    hidden: true,
    children: []
  },
]

let addRouter = [
  {
    path: '/',       
    iconCls: 'el-icon-tickets', // 图标样式class
    name: routeName.article,
    component: Layout,
    children: [
      {
        path: '/addChoice',    //题库管理->选择题增加
        iconCls: 'el-icon-edit-outline', // 图标样式class
        name: routeName.publishArticle,
        component: AddArticle,
        children: []
      },
      {
        path: '/choiceList',     //题库管理->选择题列表
        iconCls: 'el-icon-edit-outline', // 图标样式class
        name: routeName.publishArticleEditor,
        component: AddArticleEditor,
        children: []
      }
    ]
  },
  {
    path: '/',   //课程管理
    iconCls: 'fa fa-paw', // 图标样式class
    name: routeName.icon,   
    component: Layout,
    children: [
      {
        path: '/addLesson',
        iconCls: 'fa fa-life-ring', // 图标样式class
        name: routeName.addLesson,
        component: addLesson,
        children: []
      },
      {
        path: '/lessonList',
        iconCls: 'fa fa-life-ring', // 图标样式class
        name: routeName.lessonList,
        component: lessonEditor,
        children: []
      }
    ]
  },
  {
    path: '/',      //在线考试
    iconCls: 'fa fa-exchange', // 图标样式class
    name: routeName.shuttleBox,
    component: Layout,
    children: [
      {
        path: '/exam',
        iconCls: 'fa fa-life-ring', // 图标样式class
        name: routeName.shuttleBox,
        component: Exam,
        children: []
      }
    ]
  },
  {
    path: '/',         //用户管理
    iconCls: 'fa fa-life-ring', // 图标样式class
    name: routeName.permissions,
    component: Layout,
    children: [
      {
        path: '/userAdd',
          iconCls: 'fa fa-life-ring', // 图标样式class
          name: routeName.userAdd,
          component: UserAdd,
          children: []
      },
      {
        path: '/userList',
          iconCls: 'fa fa-life-ring', // 图标样式class
          name: routeName.userList,
          component: UserList,
          children: []
      },
      {
        path: '/userDetail',
          iconCls: 'fa fa-life-ring', // 图标样式class
          name: routeName.userDetail,
          component: UserDetail,
          children: []
      },
      {
        path: '/changePass',
          iconCls: 'fa fa-life-ring', // 图标样式class
          name: routeName.changePass,
          component: ChangePass,
          children: []
      }
    ]
  },
  {
    path: '/',
    iconCls: 'fa fa-newspaper-o', // 图标样式class
    name: routeName.table,
    component: Layout,
    children: [
      {
        path: '/examSetting',
          iconCls: 'fa fa-life-ring', // 图标样式class
          name: routeName.examSetting,
          component: examSetting,
          children: []
      }
    ]
  },

  {
    path: '/',
    iconCls: 'fa fa-server',
    name: routeName.multiDirectory,
    component: Layout,
    children: [
    ]
  },
  {
    path: '/',
    iconCls: 'fa fa-cloud-upload', // 图标样式class
    name: routeName.upload,
    component: Layout,
    meta: {role: ['superAdmin']},
    children: [
    ]
  },
  {
    path: '/',
    iconCls: 'el-icon-edit', // 图标样式class
    name: routeName.editor,
    component: Layout,
    meta: {role: ['superAdmin', 'admin']},
    children: [
    ]
  },
  {
    path: '/',
    iconCls: 'el-icon-setting', // 图标样式class
    name: routeName.systemSettings,
    component: Layout,
    meta: {role: ['superAdmin']},
    children: [
    ]
  },
  { path: '*',
    redirect: '/404',
    hidden: true,
    children: []
  },

]
export default new Router({
  routes: defaultRouter
})
export {defaultRouter, addRouter}
